clear all

*set working directory
use "data_study2.dta", replace

*recode PID
gen PID=pid
recode PID 1=2 2=6 3/4=4
recode PID 2=1 if pidd==1
recode PID 6=7 if pidr==1
recode PID 4=3 if pidi==1
recode PID 4=5 if pidi==2
gen PIDext=abs(PID-4)
replace PIDext=PIDext/3
label variable PIDext "Partisan Strength"

*attention to survey
rename BPAQ_2 check
recode check 1=1 *=0
label variable check "Survey Attention"

*trait aggression
recode BPAQ* (1=6) (2=5) (3=4) (4=3) (5=2) (6=1)
alpha BPAQ*, item casewise gen(TraitAgg)
replace TraitAgg=(TraitAgg-1)/5
label variable TraitAgg "Trait Aggression"

recode llviolence* Q18* Q19* Q20* Q21* (8=0) (7=1) (6=2) (5=3) (4=4)

egen polviolence_r=rowmean(Q18_*)
egen polviolence_d=rowmean(Q19_*)

egen voterviolence_r=rowmean(Q21_*)
egen voterviolence_d=rowmean(Q20_*)

egen votersum=rowfirst(voterviolence*)
egen polsum=rowfirst(polviolence*)
egen llsum=rowmean(llviolence*)

egen violencesum=rowfirst(votersum polsum llsum) 
gen expcond=.
replace expcond=0 if votersum!=.
replace expcond=1 if polsum!=.
replace expcond=2 if llsum!=.
label define lexp 0 "Voter" 1 "Politician" 2 "Most Harm", replace
label values expcond lexp

*individual items - car, rocks, punch, brick, threat, curse
egen Car=rowfirst(llviolence_1 Q18_1 Q19_1 Q20_1 Q21_1)
egen Rocks=rowfirst(llviolence_2 Q18_2 Q19_2 Q20_2 Q21_2)
egen Punch=rowfirst(llviolence_3 Q18_3 Q19_3 Q20_3 Q21_3)
egen Brick=rowfirst(llviolence_4 Q18_4 Q19_4 Q20_4 Q21_4)
egen Threat=rowfirst(llviolence_5 Q18_5 Q19_5 Q20_5 Q21_5)
egen Curse=rowfirst(llviolence_6 Q18_6 Q19_6 Q20_6 Q21_6)

gen Car_ll=Car if expcond==2
gen Car_pol=Car if expcond==1
gen Car_voter=Car if expcond==0

gen Rocks_ll=Rocks if expcond==2
gen Rocks_pol=Rocks if expcond==1
gen Rocks_voter=Rocks if expcond==0

gen Punch_ll=Punch if expcond==2
gen Punch_pol=Punch if expcond==1
gen Punch_voter=Punch if expcond==0

gen Brick_ll=Brick if expcond==2
gen Brick_pol=Brick if expcond==1
gen Brick_voter=Brick if expcond==0

gen Threat_ll=Threat if expcond==2
gen Threat_pol=Threat if expcond==1
gen Threat_voter=Threat if expcond==0

gen Curse_ll=Curse if expcond==2
gen Curse_pol=Curse if expcond==1
gen Curse_voter=Curse if expcond==0

recode *_ll *_voter *_pol (0/2=0) (3/4=1)

*averaging endorsement across items
egen LLperc=rowmean(*_ll)
egen polperc=rowmean(*_pol)
egen voterperc=rowmean(*_voter)


************
* analysis *
************

*dropping respondents with invalid most harmful actor
tab llvalid

*mean levels of support for aggressoin
sum votersum polsum llsum if llvalid==2

*pre-reg analysis
tobit violencesum i.expcond PIDext TraitAgg check if llvalid==2, ll(0) ul(4)
lincom 2.expcond-1.expcond

*endorsment rate averaged across items
sum *perc if llvalid==2

*comparison to Holliday et al.
tab Rocks_voter if llvalid==2
tab Rocks_pol if llvalid==2
tab Rocks_ll if llvalid==2


** robustness table

*pre-reg
tobit violencesum i.expcond PIDext TraitAgg check if llvalid==2, ll(0) ul(4)
lincom 2.expcond-1.expcond
est store m1

*robust to full sample
tobit violencesum i.expcond PIDext TraitAgg check, ll(0) ul(4)
lincom 2.expcond-1.expcond
est store m1b

*robust to dropping pure independents
tobit violencesum i.expcond PIDext TraitAgg check if PID!=4 & llvalid==2, ll(0) ul(4)
lincom 2.expcond-1.expcond
est store m2

*robust to no control variables
tobit violencesum i.expcond if llvalid==2, ll(0) ul(4)
lincom 2.expcond-1.expcond
est store m3

*robust to simple OLS
reg violencesum i.expcond if llvalid==2
lincom 2.expcond-1.expcond
est store m4

*robust to OLS with controls
reg violencesum i.expcond PIDext TraitAgg check if llvalid==2
lincom 2.expcond-1.expcond
est store m5

esttab m1 m1b m2 m3 m4 m5, drop(0.expcond) se(2) b(2) r2(2) pr2(2) label




*figure 7
gen xc=.

gen mean=.
gen lo=.
gen hi=.
ci means violencesum if expcond==0
replace mean=r(mean) in 1
replace lo=r(lb) in 1
replace hi=r(ub) in 1
replace xc=1 in 1
ci means violencesum if expcond==1
replace mean=r(mean) in 2
replace lo=r(lb) in 2
replace hi=r(ub) in 2
replace xc=2 in 2
ci means violencesum if expcond==2
replace mean=r(mean) in 3
replace lo=r(lb) in 3
replace hi=r(ub) in 3
replace xc=3 in 3

graph twoway (bar mean xc if xc==1) (bar mean xc if xc==2) (bar mean xc if xc==3) (rcap lo hi xc, lcol(gs5)),  ylab(0(.25)1) xtitle("") xlab("") legend(order(1 "Voters" 2 "Politicians" 3 "Most Harmful") rows(1) pos(6)) subtitle("Average Endorsement of Aggression") saving(mean_scale.gph, replace)
*xlab(1 "Voters" 2 "Politicians" 3 "Least-Liked") 

*item analysis
rename Car act1
rename Rocks act2
rename Threat act3
rename Brick act4
rename Punch act5
rename Curse act6

recode act* (0/2=0) (3/4=1)

gen actmean=.
gen alo=.
gen ahi=.
gen axc=0 if _n<7
recode axc .=1 if _n<13
recode axc .=2 if _n<19
gen acttype=.

forval x=1/6 {
	ci proportion act`x' if expcond==0
	replace actmean=r(mean) in `x'
	replace alo=r(lb) in `x'
	replace ahi=r(ub) in `x'
	replace acttype=`x' in `x'
}

local i=6
forval x=1/6 {
	local i=`i'+1
	di `i'
	ci proportion act`x' if expcond==1
	replace actmean=r(mean) in `i'
	replace alo=r(lb) in `i'
	replace ahi=r(ub) in `i'
	replace acttype=`x' in `i'
}

local i=12
forval x=1/6 {
	local i=`i'+1
	di `i'
	ci proportion act`x' if expcond==2
	replace actmean=r(mean) in `i'
	replace alo=r(lb) in `i'
	replace ahi=r(ub) in `i'
	replace acttype=`x' in `i'
}

gen intx=.
replace intx=1 if axc==0 & acttype==1
replace intx=2 if axc==1 & acttype==1
replace intx=3 if axc==2 & acttype==1

replace intx=5 if axc==0 & acttype==2
replace intx=6 if axc==1 & acttype==2
replace intx=7 if axc==2 & acttype==2

replace intx=9 if axc==0 & acttype==3
replace intx=10 if axc==1 & acttype==3
replace intx=11 if axc==2 & acttype==3

replace intx=13 if axc==0 & acttype==4
replace intx=14 if axc==1 & acttype==4
replace intx=15 if axc==2 & acttype==4

replace intx=17 if axc==0 & acttype==5
replace intx=18 if axc==1 & acttype==5
replace intx=19 if axc==2 & acttype==5

replace intx=21 if axc==0 & acttype==6
replace intx=22 if axc==1 & acttype==6
replace intx=23 if axc==2 & acttype==6

graph twoway (bar actmean intx if axc==0, horiz)  (bar actmean intx if axc==1, horiz) (bar actmean intx if axc==2, horiz ylab(2 "Car" 6 "Rocks" 10 "Threat" 14 "Brick" 18 "Punch" 22 "Curse") ytitle("") subtitle("Proportion Supporting Each Action")) (rcap alo ahi intx, legend(off) col(gs5) horiz), saving(prop_item.gph, replace)


grc1leg mean_scale.gph prop_item.gph, legendfrom(mean_scale.gph)
